package com.netease.nie.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.base.utils.CopyUtils;
import com.netease.nie.common.CommonService;
import com.netease.nie.constants.PublishedConstants;
import com.netease.nie.dao.RobGoodsInfoPeriodDao;
import com.netease.nie.dto.RobGoodsInfoPeriodDto;
import com.netease.nie.model.RobGoodsInfoPeriod;

@Service
public class RobGoodsInfoPeriodServiceImpl extends CommonService implements RobGoodsInfoPeriodService {

	@Autowired
	private RobGoodsInfoPeriodDao robGoodsInfoPeriodDao;
	
	public List<RobGoodsInfoPeriodDto> queryMaxPeriodRobGoodsInfoPeriodDtosByRobGoodsIds(
			List<Integer> robGoodsIds) {
		List<RobGoodsInfoPeriod> robGoodsInfoPeriodList = robGoodsInfoPeriodDao.queryMaxPeriodRobGoodsInfoPeriodsByRobGoodsIds(robGoodsIds);
		List<RobGoodsInfoPeriodDto> robGoodsInfoPeriodDtoList =	generateRobGoodsInfoPeriodDtoList(robGoodsInfoPeriodList);
		return robGoodsInfoPeriodDtoList;
	}

	public List<RobGoodsInfoPeriodDto> queryRobGoodsInfoPublishedPeriodDtosByRobGoodsId(
			int robGoodsId) {
		List<RobGoodsInfoPeriod> robGoodsInfoPeriodList = robGoodsInfoPeriodDao.queryRobGoodsInfoPublishedPeriodsByRobGoodsId(robGoodsId);
		List<RobGoodsInfoPeriodDto> robGoodsInfoPeriodDtoList =	generateRobGoodsInfoPeriodDtoList(robGoodsInfoPeriodList);
		return robGoodsInfoPeriodDtoList;
	}

	public RobGoodsInfoPeriodDto queryRobGoodsInfoPeriodDtoByDisplayPeriod(
			int displayPeriod) {
		RobGoodsInfoPeriodDto robGoodsInfoPeriodDto = null;
		RobGoodsInfoPeriod robGoodsInfoPeriod = robGoodsInfoPeriodDao.queryRobGoodsInfoPeriodByDisplayPeriod(displayPeriod);
		if (robGoodsInfoPeriod != null) {
			robGoodsInfoPeriodDto = new RobGoodsInfoPeriodDto();
			CopyUtils.copy(robGoodsInfoPeriodDto, robGoodsInfoPeriod);
		}
		return robGoodsInfoPeriodDto;
	}

	public List<RobGoodsInfoPeriodDto> queryUserRobGoodsInfoPeriodDtosByUserId(
			long userId, PublishedConstants publishedConstants, int pageIndex, int pageSize) {
		List<RobGoodsInfoPeriod> robGoodsInfoPeriodList = robGoodsInfoPeriodDao.queryUserRobGoodsInfoPeriodsByUserId(userId, publishedConstants, pageIndex, pageSize);
		List<RobGoodsInfoPeriodDto> robGoodsInfoPeriodDtoList =	generateRobGoodsInfoPeriodDtoList(robGoodsInfoPeriodList);
		return robGoodsInfoPeriodDtoList;
	}

	public List<RobGoodsInfoPeriodDto> queryUserRobGoodsInfoPeriodDtosByUserId(
			long userId, int pageIndex, int pageSize) {
		List<RobGoodsInfoPeriod> robGoodsInfoPeriodList = robGoodsInfoPeriodDao.queryUserRobGoodsInfoPeriodsByUserId(userId, pageIndex, pageSize);
		List<RobGoodsInfoPeriodDto> robGoodsInfoPeriodDtoList =	generateRobGoodsInfoPeriodDtoList(robGoodsInfoPeriodList);
		return robGoodsInfoPeriodDtoList;
	}
	
}
